const getAverage = scores => {
  let sum = 0;
  for (const score of scores) sum += score;
  return sum / scores.length;
}

const getGrade = score => {
  if (score === 100) {
    return "A+";
  } else if (score >= 90) {
    return "A";
  } else if (score >= 80) {
    return "B";
  } else if (score >= 70) {
    return "C";
  } else if (score >= 60) {
    return "D";
  } else {
    return "F";
  }
}

const hasPassingGrade = score => {
  if (getGrade(score) === "F") {
    return false;
  } else {
    return true;
  }
}

const studentMsg = (scores, score) => {
  const aver = getAverage(scores);
  const grade = getGrade(score);
  const hasPassed = hasPassingGrade(score);
  if (hasPassed) {
    return `Class average: ${aver}. Your grade: ${grade}. You passed the course.`;
  } else {
    return `Class average: ${aver}. Your grade: ${grade}. You failed the course.`;
  }
}

let msg = studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37);
console.log(msg);